#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "log_h"
#include "ability_h"
#include "custom_constants_h"

void _FixQuickBar(object pc)
{
    int i;
    for (i = 0; i < 200; i++)
    {
        if (GetQuickslot(pc, i) > 9000000)
        {
            SetQuickslot(pc, i, GetQuickslot(pc, i)-9000000);
        }
    }
}

void main()
{
    ALL_SPELLS_CAN_LEARN = TRUE;
    ALL_SPELLS_CAN_LEARN_DAA = TRUE;
    event ev = GetCurrentEvent();
    int nEvent =GetEventType(ev);
    Log_Events("", ev);
    int nAbility;
    int nSpell;
    string sDebug;
    object oPC = GetHero();
    object oParty = GetParty(oPC);
    int nFake = FALSE;
    switch (nEvent)
    {

            case EVENT_TYPE_COMMAND_PENDING:
            {
                nAbility = GetEventInteger(ev, 1);
                nSpell = GetEventInteger(ev, 0);
                if (nAbility > 9000000)
                {
                    (nFake = TRUE);
                }
                if (nSpell > 9000000)
                {
                    (nFake = TRUE);
                }
            }
        case EVENT_TYPE_GAMEMODE_CHANGE:
        {
            if (nFake = TRUE)
            {
                (nFake = FALSE);
                _FixQuickBar(GetMainControlled());
            }
            else
            {
                Log_Trace(LOG_CHANNEL_EVENTS, GetCurrentScriptName(), Log_GetEventNameById(nEvent) + " (" + ToString(nEvent) + ") *** Unhandled event ***");
            }
        }
        if (ALL_BACKGROUNDS = FALSE)
        {
            if ((nEvent >= EVENT_TYPE_CHARGEN_START && nEvent <= EVENT_TYPE_CHARGEN_END) || nEvent == EVENT_TYPE_PLAYERLEVELUP )
            {
                HandleEvent(ev, R"ascl_sys_chargen.ncs");
            }
        }
        break;
    }
}